#pragma once
#include "napi/native_api.h"
#include <bits/alltypes.h>
#include <hiappevent/hiappevent.h>


//导出NAPI所需要的方法
void ExportNAPIFunction(napi_env env, napi_value exports);

////从主线程发起回调
//void DispatchEvent(napi_env env, napi_value value);
////从其它线程发起回调
//void DispatchEventThread(napi_env env, napi_value value);

enum DispatchEventType:uint32_t
{
    Touch,
    UpdateFrame,
};
enum DispatchMode:uint32_t
{
    Direct,
    Thread_Block,
    Thread_NoBlock,
};

bool DispatchEvent(DispatchEventType type, DispatchMode mode = Thread_Block);
//得到事件寄存器
struct CallBackInfo {
    napi_env env; //哪个线程注册的，就回到哪个线程
    napi_ref ref_func; // 到function的引用
    // napi_value reg_value; // 回调参数寄存器
    //void *reg_data; // 回调数据
    //uint32_t reg_data_len;
    //napi_ref reg_ref;
};
struct CallBackData
{
    uint32_t * reg_data; // 回调数据
    uint32_t reg_data_len;
};
CallBackData GetCallBackData(DispatchEventType type);
